const http = require('http')
const fs = require('fs')
const path = require('path')
const qs = require('querystring')
const server = http.createServer()

server.on('request',(req,res)=>{
  // console.log('666')
  if(req.url.split('?')[0] == '/api/city'){
    var { pname } = qs.parse(req.url.split('?')[1])
    fs.readFile(path.join(__dirname,'./12312/city.json'),(err,data)=>{
      // console.log(data.toString());
      // console.log(JSON.parse(data.toString())[pname]);
      res.end(JSON.stringify(JSON.parse(data.toString())[pname]))
    })
  }
  else {
    res.end('龚')
  }
})
server.listen(3200,'192.168.87.34',()=>{
  console.log('监听到了');
})